//
//  JgAdsInterstitialCustomEvent.m
//  AnyThinkSDKDemo
//
//  Created by Erik on 2021/12/6.
//  Copyright © 2021 抽筋的灯. All rights reserved.
//

#import "JgAdsInterstitialCustomEvent.h"

@implementation JgAdsInterstitialCustomEvent
- (void)loadInterstitialAdWithPosId:(NSString *)posId{
    self.interstitialAdContainer = [[JgAdsInterstitialAdContainer alloc] initPosId:posId delegate:self];
    [self.interstitialAdContainer loadInterstitialAd];
}
- (void)showInterstitialAdAdWithRootViewController:(UIViewController *)controller{
    if(self.isReady){
        [self.interstitialAdContainer showInterstitialAdWithRootViewController:controller];
    }
}
/**
 *  插屏广告数据请求成功
 */
- (void)jgadsInterstitialSuccessToLoadAd:(JgAdsInterstitialAd *)unifiedInterstitial {
    self.isReady = YES;
    [self trackInterstitialAdLoaded:self.interstitialAdContainer adExtra:nil];
}

/**
 *  插屏广告数据请求失败
 */
- (void)jgadsInterstitialFailToLoadAd:(JgAdsInterstitialAd *)unifiedInterstitial error:(NSError *)error {
    [_interstitialAdContainer close];
    [self trackInterstitialAdLoadFailed:error];
}

/**
 *  插屏广告渲染成功
 *  建议在此回调后展示广告
 */
- (void)jgadsInterstitialRenderSuccess:(JgAdsInterstitialAd *)unifiedInterstitial {
    
}

/**
 *  插屏广告视图展示成功回调
 *  插屏广告展示成功回调该函数
 */
- (void)jgadsInterstitialDidPresentScreen:(JgAdsInterstitialAd *)unifiedInterstitial {
    
}

/**
 *  插屏广告视图展示失败回调
 *  插屏广告展示失败回调该函数
 */
- (void)jgadsInterstitialFailToPresent:(JgAdsInterstitialAd *)unifiedInterstitial error:(NSError *)error {
    [_interstitialAdContainer close];
    [self trackInterstitialAdShowFailed:error];
}

/**
 *  插屏广告曝光回调
 */
- (void)jgadsInterstitialWillExposure:(JgAdsInterstitialAd *)unifiedInterstitial {
    [self trackInterstitialAdShow];
}

/**
 *  插屏广告点击回调
 */
- (void)jgadsInterstitialClicked:(JgAdsInterstitialAd *)unifiedInterstitial {
    [self trackInterstitialAdClick];
}

/**
 *  插屏广告页关闭
 */
- (void)jgadsInterstitialAdDidDismissClose:(JgAdsInterstitialAd *)unifiedInterstitial {
    [_interstitialAdContainer close];
    [self trackInterstitialAdClose:nil];
}

- (NSString *)networkUnitId {
    return self.serverInfo[@"slot_id"];
}

@end
